<?php
class lapkwitansicontroller extends CI_Controller{
	function __construct(){
		parent::__construct();
		$this->load->helper('form');
		$this->load->library('form_validation');
		$this->load->model('lapkwitansi_model');
	}
	
	function index(){
		if (isset($_POST['btnview']))
		{
			$pilih = trim($_POST['choose']);
			$tglawal = trim($_POST['tglawal']);
			$tglakhr = trim($_POST['tglakhir']);
		}else{			
			$pilih = "";
			$tglawal = "";
			$tglakhr = "";
		}
		
		if ($pilih=="J")
		{
			$data = $this->lapkwitansi_model->getkwitansipenjualan($tglawal,$tglakhr);
		}else{
			$data = $this->lapkwitansi_model->getkwitansipembelian($tglawal,$tglakhr);
		}

		$dataprofile = array(
			'page_title' => 'Laporan > Kwitansi',
			'name' => $this->session->userdata('fullname'),
			'data' => $data	
		);
		$content = array(
		  	'content' => 'laporan/reportkwitansi'
		);
		$this->template->load('templates/default',$content,$dataprofile);
	}
	
	function toExcel()
	{
		if ($_REQUEST['choose']=="J")
		{
			$data = $this->lapkwitansi_model->getkwitansipenjualan($_REQUEST['tglawal'],$_REQUEST['tglakhir']);
		}else{
			$data = $this->lapkwitansi_model->getkwitansipembelian($_REQUEST['tglawal'],$_REQUEST['tglakhir']);
		}

		$dataprofile = array
		(
			'page_title' => '',
			'name' => '',
			'jenis' => $_REQUEST['choose'],
			'data' => $data
		);			

		$this->load->view('laporan/excelreportkwitansi',$dataprofile);
	}
}